$(document).ready(function() {
    var authenticity_token = $('#hidden_form input').val();
    var update_url = "/categories/update?authenticity_token=" + authenticity_token

    $(".edit_name").editable(update_url,
    {
        name : 'category[name]',
        indicator : "提交中..",
        tooltip   : '点击编辑',
        onblur : 'submit',
        event  : 'dblclick'
    });

    $(".edit_parent").editable(update_url,
    {
        name : 'category[parent_id]',
        loadurl : "/categories/json_for_select",
        type : 'select',
        indicator : "提交中..",
        tooltip   : '点击编辑',
        onblur : 'submit',
        event  : 'dblclick'
    });

    $(".edit_unit").editable(update_url,
    {
        name : 'category[unit]',
        data : "{'1':'台','2':'支','3':'副'}",
        type : 'select',
        indicator : "提交中..",
        tooltip   : '点击编辑',
        onblur : 'submit',
        event  : 'dblclick'
    });
});


